using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Data_TempReflection_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Data.TempReflection);
            args = new Type[]{typeof(System.Type)};
            method = type.GetMethod("ObjectFields", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, ObjectFields_0);
            args = new Type[]{typeof(System.Object)};
            method = type.GetMethod("ObjectFields", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, ObjectFields_1);

            field = type.GetField("Top", flag);
            app.RegisterCLRFieldGetter(field, get_Top_0);
            app.RegisterCLRFieldSetter(field, set_Top_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_Top_0, AssignFromStack_Top_0);
            field = type.GetField("All", flag);
            app.RegisterCLRFieldGetter(field, get_All_1);
            app.RegisterCLRFieldSetter(field, set_All_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_All_1, AssignFromStack_All_1);


            app.RegisterCLRCreateDefaultInstance(type, () => new huqiang.Data.TempReflection());
            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Data.TempReflection[s]);

            args = new Type[]{};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }


        static StackObject* ObjectFields_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Type @type = (System.Type)typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = huqiang.Data.TempReflection.ObjectFields(@type);

            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static StackObject* ObjectFields_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Object @obj = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = huqiang.Data.TempReflection.ObjectFields(@obj);

            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


        static object get_Top_0(ref object o)
        {
            return ((huqiang.Data.TempReflection)o).Top;
        }

        static StackObject* CopyToStack_Top_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.TempReflection)o).Top;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Top_0(ref object o, object v)
        {
            ((huqiang.Data.TempReflection)o).Top = (System.Int32)v;
        }

        static StackObject* AssignFromStack_Top_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int32 @Top = ptr_of_this_method->Value;
            ((huqiang.Data.TempReflection)o).Top = @Top;
            return ptr_of_this_method;
        }

        static object get_All_1(ref object o)
        {
            return ((huqiang.Data.TempReflection)o).All;
        }

        static StackObject* CopyToStack_All_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.TempReflection)o).All;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_All_1(ref object o, object v)
        {
            ((huqiang.Data.TempReflection)o).All = (huqiang.Data.ReflectionModel[])v;
        }

        static StackObject* AssignFromStack_All_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            huqiang.Data.ReflectionModel[] @All = (huqiang.Data.ReflectionModel[])typeof(huqiang.Data.ReflectionModel[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Data.TempReflection)o).All = @All;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new huqiang.Data.TempReflection();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
